"""
______________________________
time：2021/6/21
______________________________
xbb登录页面——选择公司页面
"""

from time import sleep

from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


class LoginChoosePage:
    company_loc = (By.XPATH, '//p[@class="company-name" and contains(text(),"帮你瘦瘦瘦网络科技有限公司")]')
    loginhome_loc = (By.XPATH, '//button[contains(@class,"login-btn")]')

    def __init__(self, driver: WebDriver):
        self.driver = driver
        self.wait = WebDriverWait(driver, 5)

    def choose_company(self):
        try:
            # 选择帮你瘦瘦瘦网络科技有限公司，然后点击”立即进入“
            self.wait.until(EC.visibility_of_element_located(self.loginhome_loc))
            self.driver.find_element(*self.company_loc).click()
        except:
            return False
        else:
            self.driver.find_element(*self.loginhome_loc).click()
